<?php
namespace app\admin\controller;

class Orderconvert extends Admin{
    public function __construct(){
        parent::__construct();
        $this->model = 'OrderConvert';
        $this->assign("model",$this->model);
    }
    public function index(){
    	
    	return $this->fetch();
    }
    public function adddesc(){
    	$id = input("param.id");
    	$info = model($this->model)->get_data(['item_id'=>$id]);
    	$this->assign('info', $info);
    	return $this->fetch();
    }
    public function data_update(){
        $db = model($this->model);
        $postData = input("post.postData");
        parse_str($postData,$dataarr);
        $info = $db->get_data(['item_id'=>$dataarr['id']]);
        if ($info['status'] == 0) {
        	return json(['status' => 0,'msg'=>'对方尚未付款']);
        }
        if ($info['status'] == 3) {
        	return json(['status' => 0,'msg'=>'已经收货无法修改']);
        }
        $dataarr['status'] = 2;
        $id = $db->update_data($dataarr);
        if($id === false){
            return json(['status' => 0,'msg'=>$db->getError()]);
        }
        return json(['status' => 1,'msg'=>'操作成功']);
    }
}